/*
 * Funny Language - a free style programming language.
 * Copyright (C) 2015 by fanguangping (fanguangping@163.com)
 * tree.h
 */

#ifndef FUNNY_SCHEME_TREE_H
#define FUNNY_SCHEME_TREE_H

#include "queue.h"

typedef char * (*ConvertName)(char *);

typedef struct _TreeNode {
	const char *name;
	void *data;
	struct _TreeNode *parent;
	Queue *children;
} TreeNode;

typedef struct _Tree {
	TreeNode *root;
} Tree;

Tree *alloc_tree();
TreeNode *alloc_tree_node();

Tree *init_tree();
TreeNode *tree_find(Tree *tree, const char *name);
TreeNode *tree_add(Tree *tree, const char *parentName, const char *name, void *data);
Tree* construct_tree(Tree*, char *hierarchy, char prefix, ConvertName converter);

#endif //FUNNY_SCHEME_TREE_H
